]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
components/autorunManager: Use notification actions API
authorJulian Sparber <julian@sparber.net>
Fri, 9 Feb 2024 11:55:44 +0000 (12:55 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 3 Mar 2024 01:33:16 +0000 (01:33 +0000)
Stop using custom buttons for notification actions. The only reason to
use custom buttons was so that we could add icons next to the button
label, if we really need the icons next to the label we can add icons to
the notification API.
By using the actions API we can ensure that buttons always look the
same without additional work.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3173>

data/theme/gnome-shell-sass/_widgets.scss
data/theme/gnome-shell-sass/widgets/_hotplug.scss [deleted file]
data/theme/meson.build
js/ui/components/autorunManager.js

index ee16a7141da1e9364a5c2d573b7712cf0a1e5710..9eac62d958abb05ae1e2c9730978355f986f4d18 100644 (file)
@@ -21,7 +21,6 @@
 @import 'widgets/ibus-popup';
 // Notifications
 @import 'widgets/notifications';
-@import 'widgets/hotplug';
 // Dialogs
 @import 'widgets/dialogs';
 // OSDs
diff --git a/data/theme/gnome-shell-sass/widgets/_hotplug.scss b/data/theme/gnome-shell-sass/widgets/_hotplug.scss
deleted file mode 100644 (file)
index f20626b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// hotplug
-
-.hotplug-notification-item {
-  @extend %bubble_button;
-}
-
-.hotplug-notification-item-icon {
-  icon-size: $medium_icon_size;
-  padding: 0 $base_margin;
-}
index 0d28efd038181fa38f0639a8ce4607fdece77191..8d01ae826dbfcd361d25d86dbca5bfc06fb3369d 100644 (file)
@@ -17,7 +17,6 @@ theme_sources = files([
   'gnome-shell-sass/widgets/_dash.scss',
   'gnome-shell-sass/widgets/_dialogs.scss',
   'gnome-shell-sass/widgets/_entries.scss',
-  'gnome-shell-sass/widgets/_hotplug.scss',
   'gnome-shell-sass/widgets/_ibus-popup.scss',
   'gnome-shell-sass/widgets/_keyboard.scss',
   'gnome-shell-sass/widgets/_login-lock.scss',
index d2b69d67e1302f027f7b9f6c4f093f8b17a8e6e5..7e53f8396ba85df8ed50dbaa5caa9a9310ace711 100644 (file)
@@ -1,9 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
-import Clutter from 'gi://Clutter';
 import Gio from 'gi://Gio';
-import GObject from 'gi://GObject';
-import St from 'gi://St';
 
 import * as GnomeSession from '../../misc/gnomeSession.js';
 import * as MessageTray from '../messageTray.js';
@@ -190,7 +187,20 @@ class AutorunDispatcher {
             return;
 
         const source = MessageTray.getSystemSource();
-        const notification = new AutorunNotification(source, mount, apps);
+        const notification = new MessageTray.Notification(
+            source,
+            mount.get_name()
+        );
+        notification.connect('activate', () => {
+            const app = Gio.app_info_get_default_for_type('inode/directory', false);
+            startAppForMount(app, mount);
+        });
+        apps.forEach(app => {
+            notification.addAction(
+                _('Open with %s').format(app.get_name()),
+                () => startAppForMount(app, mount)
+            );
+        });
         notification.connect('destroy', () => this._notifications.delete(mount));
         this._notifications.set(mount, notification);
         source.showNotification(notification);
@@ -238,70 +248,4 @@ class AutorunDispatcher {
     }
 }
 
-const AutorunNotification = GObject.registerClass(
-class AutorunNotification extends MessageTray.Notification {
-    constructor(source, mount, apps) {
-        super(source, mount.get_name());
-
-        this.gicon = mount.get_icon();
-
-        this._mount = mount;
-        this._apps = apps;
-    }
-
-    createBanner() {
-        let banner = new MessageTray.NotificationBanner(this);
-
-        this._apps.forEach(app => {
-            let actor = this._buttonForApp(app);
-
-            if (actor)
-                banner.addButton(actor);
-        });
-
-        return banner;
-    }
-
-    _buttonForApp(app) {
-        let box = new St.BoxLayout({
-            x_expand: true,
-            x_align: Clutter.ActorAlign.START,
-        });
-        const icon = new St.Icon({
-            gicon: app.get_icon(),
-            style_class: 'hotplug-notification-item-icon',
-        });
-        box.add_child(icon);
-
-        let label = new St.Bin({
-            child: new St.Label({
-                text: _('Open with %s').format(app.get_name()),
-                y_align: Clutter.ActorAlign.CENTER,
-            }),
-        });
-        box.add_child(label);
-
-        const button = new St.Button({
-            child: box,
-            x_expand: true,
-            button_mask: St.ButtonMask.ONE,
-            style_class: 'hotplug-notification-item button',
-        });
-
-        button.connect('clicked', () => {
-            startAppForMount(app, this._mount);
-            this.destroy();
-        });
-
-        return button;
-    }
-
-    activate() {
-        super.activate();
-
-        let app = Gio.app_info_get_default_for_type('inode/directory', false);
-        startAppForMount(app, this._mount);
-    }
-});
-
 export {AutorunManager as Component};